/*
 * BitbltLayerMerger.h
 *
 *  Created on: 2010-9-19
 *      Author: try
 */

#ifndef BITBLTLAYERMERGER_H_
#define BITBLTLAYERMERGER_H_
#include "../draw/LayerMerger.h"
#include "gdiplus_commons.h"

namespace Ed {
  class DrawPage;
  class Layer;

  /**
   * Bitblt模式层合并，无透明效果，但能得到更好的性能
   */
  class BitbltLayerMerger: public Ed::LayerMerger {
    public:
      BitbltLayerMerger(DrawPage* page);
      virtual ~BitbltLayerMerger();

      /**
       * 将图层与目标设备合并
       */
      virtual bool merge();

    private:
      DrawPage* page;

      struct BufferItem{
          HDC bufferDC;
          Gdiplus::Graphics* graphics;
      };

      typedef hash_map<long, BufferItem*> LayerBufferMap;
      LayerBufferMap layerBufferMap;

      /**
       * 返回BufferItem
       */
      BufferItem* getBufferItem(Layer* l);

  };

}

#endif /* BITBLTLAYERMERGER_H_ */
